package study.day6.t4;

//LinkedList 的使用

import java.util.LinkedList;
import java.util.List;

public class T4 {
    public static void main(String[] args) {
        List list=new LinkedList();
        Book b1=new Book("你是人间的四月天",60,"林徽因");
        list.add(b1);
        Book b2=new Book("平凡的世界",70,"路遥");
        Book b3=new Book("活着",80,"余华");
        list.addFirst(b2);;
        list.addLast(b3);
        //获取第一本书
        Book first = (Book) list.getFirst();
        System.out.println(first.getName());
        System.out.println("=====================");
        //获取最后一本书
        Book last = (Book) list.getLast();
        System.out.println(last.getName());
        System.out.println("=====================");
        //删除元素
        list.removeFirst();
        list.removeLast();
        //遍历元素
        for(int i=0;i<list.size();i++){
            Book book=(Book)list.get(i);
            System.out.println(book);
        }
    }
}
